package collect.map;
import java.util.TreeMap;
import java.util.function.BiConsumer;
public class TestTreeMap3 {
    public static void main(String[] args) {
        String user = "aaddcbsdadda";
        TreeMap<Character, Integer> tm = new TreeMap<>();
        for (int i = 0; i < user.length(); i++) {
            char c = user.charAt(i);
            if (tm.containsKey(c)) {
                //存在
                Integer integer = tm.get(c);
                integer++;
                tm.put(c, integer);
            } else {
                //不存在
                tm.put(c, 1);
            }
        }
        StringBuilder sb = new StringBuilder();
        tm.forEach(new BiConsumer<Character, Integer>() {
            @Override
            public void accept(Character key, Integer value) {
                sb.append(key).append("(").append(value).append(")");

            }
        });
        System.out.println(sb);
    }
}
